package colm.lagou.city.controller;

import com.lagou.common.entity.Result;
import com.lagou.common.entity.StatusCode;
import jdk.net.SocketFlow;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
    try{
        int b = 0;
        int c = 12/0;
       }catch (Exception e){        //虚拟机 new Exception();
          e.getMessage();
       }
 **/

@ControllerAdvice
public class BaseException {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody   //可以返回页面
    public Result error(Exception e){    //没有new，直接 e.getMessage();
        return new Result(true, StatusCode.Fail,"服务忙",e.getMessage());
    }
}
